home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime vr / vrmakepano / vrmakepano.h < prev    next >
Encoding:
Text File  |  2000-09-28  |  7.9 KB  |  206 lines

  1. //////////
  2. //
  3. //    File:        VRMakePano.h
  4. //
  5. //    Contains:    Code for creating a QuickTime VR panoramic movie from a panoramic image.
  6. //
  7. //    Written by:    Tim Monroe
  8. //                Based largely on MakeQTVRPanorama code by Ed Harp (and others?).
  9. //
  10. //    Copyright:    © 1996-1998 by Apple Computer, Inc., all rights reserved.
  11. //
  12. //    Change History (most recent first):
  13. //
  14. //       <1>         12/01/98    rtm        first file
  15. //       
  16. //////////
  17.  
  18. #include <Endian.h>
  19. #include <FixMath.h>
  20. #include <Math.h>
  21. #include <ImageCompression.h>
  22. #include <Movies.h>
  23. #include <QuickTimeComponents.h>
  24. #include <QuickTimeVR.h>
  25. #include <QuickTimeVRFormat.h>
  26. #include <Script.h>
  27. #include <Sound.h>
  28.  
  29. #include "ComApplication.h"
  30.  
  31. #if TARGET_OS_MAC
  32. #include "MacFramework.h"
  33. #endif
  34.  
  35. #if TARGET_OS_WIN32
  36. #include "WinFramework.h"
  37. #endif
  38.  
  39. //////////
  40. //
  41. // compiler flags
  42. //
  43. //////////
  44.  
  45. // the following flag determines whether we show the uncompressed tiles in a window as they get processed;
  46. // I did this mainly for debugging purposes, but it's also a useful progress indicator....
  47. #define USE_TILE_DISPLAY_WINDOW            1
  48.  
  49.  
  50. //////////
  51. //
  52. // constants
  53. //
  54. //////////
  55.  
  56. #define kQTVRStandardTimeScale            3600                        // time scale for QTVR panoramas
  57. #define kDefaultNodeID                    1                            // default node ID
  58. #define kNumTilesInPanoFile                24
  59. #define kPanoramaHeight                    (long)300
  60. #define kPanoramaWidth                    (long)400
  61. #define kQTVRVersion1                    (long)1
  62. #define kQTVRVersion2                    (long)2
  63. #define kPanDescType                    FOUR_CHAR_CODE('pano')
  64. #define kPanHeaderType                    FOUR_CHAR_CODE('pHdr')
  65. #define kStringTableType                FOUR_CHAR_CODE('strT')
  66. #define kHotSpotTableType                FOUR_CHAR_CODE('pHot')
  67.  
  68. #define kPanoSaveTilePrompt                "Save tile movie file as:"
  69. #define kPanoSaveTileFileName            "Untitled.til"
  70. #define kPanoSaveMoviePrompt            "Save panoramic movie file as:"
  71. #define kPanoSaveMovieFileName            "Untitled.mov"
  72.  
  73. //////////
  74. //
  75. // data types
  76. //
  77. //////////
  78.  
  79. // version 1.0 data types
  80.  
  81. #if PRAGMA_ALIGN_SUPPORTED
  82. #pragma options align=mac68k
  83. #endif
  84.  
  85. // panorama description:
  86. // this defines the structure of a sample description for a media sample in a panorama track
  87. typedef struct PanoramaDescription {
  88.     long            size;                        // total size of PanoramaDescription
  89.     long            type;                        // must be 'pano'
  90.     long            reserved1;                    // must be zero
  91.     long            reserved2;                    // must be zero
  92.     short            majorVersion;                // must be zero
  93.     short            minorVersion;                // must be zero
  94.     long            sceneTrackID;                // ID of video track that contains panoramic scene
  95.     long            loResSceneTrackID;            // ID of video track that contains lo res panoramic scene
  96.     long            reserved3[6];                // must be zero
  97.     long            hotSpotTrackID;                // ID of video track that contains hotspot image
  98.     long            loResHotSpotTrackID;        // ID of video track that contains lo res hotspot image
  99.     long            reserved4[8];                // must be zero
  100.     Fixed            hPanStart;                    // horizontal pan range start angle (eg. 0)
  101.     Fixed            hPanEnd;                    // horizontal pan range end angle (eg. 360)
  102.     Fixed            vPanTop;                    // vertical pan range top angle(eg. 42.5)
  103.     Fixed            vPanBottom;                    // vertical pan range bottom angle (eg. -42.5)
  104.     Fixed            minimumZoom;                // minimum zoom angle (eg. 5; use 0 for default))
  105.     Fixed            maximumZoom;                // maximum zoom angle (eg. 65; use 0 for default)
  106.     // info for highest res version of scene track
  107.     long            sceneSizeX;                    // pixel width of the panorama (eg. 768)
  108.     long            sceneSizeY;                    // pixel height of the panorama (eg. 2496)
  109.     long            numFrames;                    // number of diced frames (eg. 24)
  110.     short            reserved5;                    // must be zero
  111.     short            sceneNumFramesX;            // diced frames wide (eg. 1)
  112.     short            sceneNumFramesY;            // diced frames high (eg. 24)
  113.     short            sceneColorDepth;            // bit depth of the scene track (eg. 32)
  114.     // info for highest res version of hotSpot track
  115.     long            hotSpotSizeX;                // pixel width of the hot spot panorama (eg. 768)
  116.     long            hotSpotSizeY;                // pixel height of the hot spot panorama (eg. 2496)
  117.     short            reserved6;                    // must be zero
  118.     short            hotSpotNumFramesX;          // diced frames wide (eg. 1)
  119.     short            hotSpotNumFramesY;            // diced frames high (eg. 24)
  120.     short            hotSpotColorDepth;            // must be 8
  121.     
  122. } PanoramaDescription, *PanoramaDescriptionPtr, **PanoramaDescriptionHandle;
  123.  
  124. // panorama sample header atom:
  125. // this defines the structure of (part of) a media sample in a panorama track
  126. typedef struct PanoSampleHeaderAtom {
  127.     long            size;
  128.     OSType            type;                          // must be 'pHdr'
  129.     unsigned long    nodeID;                        // corresponds to a node ID in the idToTime table 
  130.     Fixed            defHPan;                    // default horizontal pan angle when displaying this node
  131.     Fixed            defVPan;                    // default vertical pan angle when displaying this node
  132.     Fixed            defZoom;                    // default zoom angle when displaying this node
  133.     Fixed            minHPan;                    // constraints for this node; use zero for default
  134.     Fixed            minVPan;
  135.     Fixed            minZoom;
  136.     Fixed            maxHPan;
  137.     Fixed            maxVPan;
  138.     Fixed            maxZoom;
  139.     long            reserved1;                    // must be zero
  140.     long            reserved2;                    // must be zero
  141.     long            nameStrOffset;                // offset into string table atom
  142.     long            commentStrOffset;            // offset into string table atom
  143. } PanoSampleHeaderAtom, *PanoSampleHeaderAtomPtr, **PanoSampleHeaderAtomHandle;
  144.  
  145. // hot spot atom
  146. typedef struct HotSpot {
  147.     unsigned short    hotSpotID;                    // the ID of this hot spot
  148.     short            reserved1;                    // must be zero
  149.     OSType            type;                        // the hot spot type (e.g. 'link',  'navg', etc)
  150.     unsigned long    typeData;                    // for link and navg, the ID in the link  and navg table
  151.     Fixed            viewHPan;                    // canonical view for this hot spot
  152.     Fixed            viewVPan;
  153.     Fixed            viewZoom;
  154.     Rect            hotSpotRect;                // bounding rectangle of the hot spot in  the panorama
  155.     long            mouseOverCursorID;
  156.     long            mouseDownCursorID;
  157.     long            mouseUpCursorID;
  158.     long            reserved2;                    // must be 0
  159.     long            nameStrOffset;                // offset into string table atom
  160.     long            commentStrOffset;            // offset into string table atom
  161. } HotSpot, *HotSpotPtr, **HotSpotHandle;
  162.  
  163. // hot spot table atom
  164. typedef struct HotSpotTableAtom {
  165.     long            size;
  166.     OSType            type;                          // must be 'pHot'
  167.     short            pad;                        // must be 0
  168.     short            numHotSpots;
  169.     HotSpot            hotSpots[1];                // list of hot spots
  170. } HotSpotTableAtom, *HotSpotTableAtomPtr, **HotSpotTableAtomHandle;
  171.  
  172.  
  173. typedef struct StringTableAtom {
  174.     long            size;
  175.     OSType            type;                        // must be 'strT'
  176.     char            bunchOstrings[1];            // concatenated Pascal strings
  177. } StringTableAtom, *StringTableAtomPtr, **StringTableAtomHandle;
  178.     
  179.     
  180. #if PRAGMA_ALIGN_SUPPORTED
  181. #pragma options align=reset
  182. #endif
  183.  
  184.  
  185.  
  186. //////////
  187. //
  188. // function prototypes
  189. //
  190. //////////
  191.  
  192. void                        VRPano_PromptUserForImageFileAndMakeMovie (void);
  193. OSErr                        VRPano_CreateVRWorld (QTAtomContainer *theVRWorld, QTAtomContainer *theNodeInfo, OSType theNodeType);
  194. OSErr                        VRPano_CreatePanoTrack (Movie theMovie, FSSpec *theSrcFile, FSSpec *theHSSrcFile, Track theQTVRTrack, Track thePanoTrack, Media thePanoMedia, long theWidth, long theHeight);
  195. OSErr                        VRPano_CreateTileMovie (GraphicsImportComponent theImporter, FSSpec *theTileSpec, CodecType theCodec, CodecQ theQuality, short theDepth);
  196. OSErr                        VRPano_CreateQTVRMovieVers1x0 (FSSpec *theMovieSpec, FSSpec *theTileSpec, FSSpec *theHSTileSpec, long theHeight, long theWidth);
  197. OSErr                        VRPano_CreateQTVRMovieVers2x0 (FSSpec *theMovieSpec, FSSpec *theTileSpec, FSSpec *theHSTileSpec, long theHeight, long theWidth);
  198. OSErr                        VRPano_MakePanorama (FSSpec *thePictSpec, FSSpec *theHSPictSpec, FSSpec *theTileSpec, FSSpec *theDestSpec, long theWidth, long theHeight, CodecType theCodec, CodecQ theQuality, long theVersion);
  199. OSErr                        VRPano_ImportVideoTrack (Movie theSrcMovie, Movie theDstMovie, TimeValue theDuration, long *theTrackWidth, long *theTrackHeight, Track *theTrack);
  200. HotSpotTableAtomHandle        VRPano_MakeHotSpotVers1x0 (StringTableAtomHandle theStringTable);
  201. OSErr                        VRPano_MakeHotSpotVers2x0 (QTAtomContainer theNodeInfo, QTAtom theHSParent, char *theURL, char *theHSName, UInt32 theIndex);
  202. OSErr                        VRPano_SetControllerType (Movie theMovie, OSType theType);
  203. OSErr                        VRPano_AddStr255ToAtomContainer (QTAtomContainer theContainer, QTAtom theParent, Str255 theString, QTAtomID *theID);
  204. void                        VRPano_ConvertFloatToBigEndian (float *theFloat);
  205.  
  206.